package com.teyao.teyao_back.controller;

import com.teyao.teyao_back.entity.Loading;
import com.teyao.teyao_back.entity.ResponseMessage;
import com.teyao.teyao_back.service.LoadingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/loading2")
public class LoadingController {
    @Autowired
    private LoadingService loadingService;

    @PostMapping("/updateByOrderId")
    public ResponseMessage updateByOrderId(String orderId, String loader) {
        Loading loading = new Loading();
        loading.setLoader(loader);
        return loadingService.updateByOrderId(orderId, loading);
    }

    @PostMapping("/save")
    public ResponseMessage save(Loading loading) {
        ResponseMessage responseMessage = new ResponseMessage();
        responseMessage.setSuccess(loadingService.save(loading));
        return responseMessage;
    }

}
